const UserRedux = (state = {
    user: null,
    token: ''
}, action) => {
    const newInitState = {...state}
    switch (action.type) {
        case 'LOGIN':
            newInitState.user = action.data.user
            newInitState.token = action.data.token
            return newInitState
        case "DEMO":
            newInitState.demo = "demo"
            return newInitState
        case "LOGOUT":
            newInitState.user = null
            newInitState.token = ''
            return newInitState
        case "EDITUSER":
            newInitState.user = action.data
            return newInitState
        default:
            return state

    }
}

export default UserRedux
